<template>
  <div class="view-box-ZQCX001" ref="viewBox">
    <div class="seckill-component" id="seckill-component" >
      <div class="app-content-box">
        <div class="top-box"></div>

        <div>
          <div class="title-box">
            <div class="title-box-text">活动内容</div>
          </div>
          <div class="content-box">
            {{seckilData.activityContent|appData('activityContent')}}
          </div>
        </div>

          <div>
            <div class="title-box">
              <div class="title-box-text">适用产品</div>
            </div>
            <div class="content-box-model">
              <el-row :gutter="10">
                <el-col :span="12" v-for="(item,index) in goodsList" :key="index" >
                  <div class="model-item">
                    <div class="model-img">
                      <el-image :src="getImgUrl(item.url)" fit="cover" style="height: 100%;width: 100%"></el-image>
                    </div>
                    <div class="model-info">
                      <div class="name">{{item.modelInfo}}</div>
                      <div class="model-price">
                        <span class="now-price">¥
                          <span style="font-size: 15px;">{{item.presentPrice}}</span>
                          {{seckilData.bizType==2?'/月':'/天'}}</span>
                        <span class="old-price">¥{{item.averagePrice}}{{seckilData.bizType==2?'/月':'/天'}}</span>
                      </div>

                      <div class="model-number">
                        <el-row :gutter="10">
                          <el-col :span="9">
                        剩余{{item.number||0}}
                          </el-col>
                          <el-col :span="11">
                        <button class="dingche" >立即订车</button>
                          </el-col>
                        </el-row>
                      </div>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </div>
          </div>


        <div>
          <div class="title-boxs">
          </div>
          <div class="content-box-store ">
            <div class="time">活动时间:{{seckilData.startTime||'2022.06.30'}}-{{seckilData.endTime||'2022.07.30'}}</div>
            <el-row :gutter="10">
              <el-col :span="10">
                <div class="store-info store-title">活动门店:</div>
              </el-col>
              <el-col :span="14">
                <div class="store-info store-name" v-for="(store,index) in activityUnit" :key="index">
                  <div>{{ store.applicableUnit }}</div></div>
              </el-col>
            </el-row>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>


let defaultData = {
  activityName: "超值立减金限时大放送",
  activityContent: "中秋活动正式开启，福利特惠面向全体用户， xx优惠券/特惠车型限时领取/秒杀"
}
export default {
  name: 'SeckillMobile',
  props: {
    seckilData: {
      activityName: {
        type: String,
        default() {
          return '0'
        },
      },
      activityContent: {
        type: String,
        default() {
          return '0'
        },
      },
      activityUnit: {
        type: Array,
        default() {
          return [{
            applicableUnit: "西安市高新科技园店",
            unitAddress: "西安市雁塔区GOGO街区"
          }]
        }
      }
    },
    goodsList: {
      type: Array,
      default() {
        return []
      },
    },
    activityUnit: {
      type: Array,
      default() {
        return []
      },
    },
  },
  filters: {
    appData(val, key) {
      if (val && val != '') {
        return val
      } else {
        return defaultData[key]
      }
    }
  },
watch:{
  activityUnit:{
    handler(val) {
      this.$forceUpdate()
    }
  },
},
  data() {
    return {
    }
  },
  mounted() {
    // js
    console.log(this.activityUnit)
    this.zoom()
    // 窗口大小变化时，需要重算
    window.addEventListener('resize', this.zoom, false)
  },
  methods:{
    zoom(){
      let domBody = document.getElementsByClassName('view-box-ZQCX001')[0]
      domBody.style.zoom = document.body.clientWidth / 22 + '%'
    }
  },
  destroyed() {
    window.removeEventListener('resize', this.zoom, false)
  },
}
</script>

<style scoped>
.seckill-component {
  background: linear-gradient(0deg,#ff9045 0%, #ff8a00 100%);
  width: 374px;
  height: 735px;
  font-size: 12px;
  margin: 0 auto;

}

.view-box-ZQCX001 {
  background: #ffffff;
  width: 432px;
  height: 865px;
  font-size: 12px;
  margin: 0 auto;
  background-image: url(../../../commImg/phone/left.png), url(../../../commImg/phone/top.png), url(../../../commImg/phone/right.png), url(../../../commImg/phone/lower.png);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  background-position: left bottom, top, right bottom, bottom;
  padding: 65px 30px 59px 29px;
}

::-webkit-scrollbar {
  width: 0 !important;
}

::-webkit-scrollbar {
  width: 0 !important;
  height: 0;
}


.app-content-box {
  height: 100%;
  width: 100%;
  overflow: auto;
}
.top-box{
  width: 100%;
  height: 243px;
  background-image: url(./img/topBg.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.title-box{
  width: 357px;
  height: 76px;
  z-index: 2;
  background-image: url(./img/titleBg.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: relative;
  margin: auto;
}
.title-boxs{
  width: 357px;
  height: 35px;
  z-index: 2;
  position: relative;
  margin: auto;
}
.title-box-text{
  margin-left: 55px;
  font-size: 18px;
  font-weight: bold;
  color: #333333;
  position: relative;
  top: 18px;
}
.content-box{
  width: 357px;
  border: 3px solid #1c1c1c;
  border-top: none;
  border-radius: 4px;
  position: relative;
  top: -30px;
  background: #f1f3f2;
  z-index: 1;
  margin: auto;
  padding: 30px 37px 20px 37px;
  font-size: 14px;
  font-weight: bold;
  text-align: left;
  color: #666666;
  line-height: 22.5px;
  letter-spacing: 0.28px;
  word-break: break-all;
}
.content-box-store{
  width: 357px;
  border: 3px solid #1c1c1c;
  border-radius: 4px;
  position: relative;
  top: -30px;
  background: #f1f3f2;
  z-index: 1;
  margin: auto;
}
.content-box-store .time{

  font-size: 14px;
  font-weight: bold;
  text-align: center;
  color: #666666;
  line-height: 32px;
  letter-spacing: 0.28px;
}
.content-box-model{
  width: 357px;
  border: 3px solid #1c1c1c;
  border-top: none;
  border-radius: 4px;
  position: relative;
  top: -30px;
  background: #f1f3f2;
  z-index: 1;
  margin: auto;
  padding: 31px 13px 10px 13px;
}

.model-item{
  width: 160.5px;
  height: 205.5px;
  background: #ffffff;
  border: 0.5px solid #bebebe;
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
}
.model-img{
  height: 85px;
}
.model-info .name{
  font-size: 14px;
  font-weight: bold;
  color: #131313;
  padding-top: 5px;
  letter-spacing: 0.35px;
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  white-space: normal !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.model-number{
  font-size: 10px;
  font-weight: bold;
  text-align: left;
  color: #999999;
  letter-spacing: 0.25px;
  height: 25px;
  line-height: 26px;
}

.now-price{
  font-size: 11px;
  font-weight: bold;
  text-align: left;
  color: #ff781f;
}
.old-price{
  font-size: 12px;
  font-weight: bold;
  text-decoration:  line-through;
  text-align: left;
  color: #aaaaaa;
  line-height: 32px;
}
.store-info{
  font-size: 15px;
  font-weight: bold;
  color: #333333;
  line-height: 25px;
  letter-spacing: 0.3px;
}
.store-title{
  text-align: right;
}
.dingche{
  width: 90px;
  height: 28px;
  background: linear-gradient(#ff500b 0%, #ff9829 99%);
  border-radius: 14px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  color: #ffffff;
  line-height: 26px;
  letter-spacing: 0.36px;
}
</style>
